﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class DragEventListener : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDragHandler,IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler
{

    public delegate void EventProxy(GameObject obj,PointerEventData eventData);

    public event EventProxy BeginDrag;
    public event EventProxy Drag;
    public event EventProxy EndDrag;
    public event EventProxy Click;
    public event EventProxy PointEnter;
    public event EventProxy PointExit;
    public event EventProxy PointDown;

    public void OnBeginDrag(PointerEventData eventData)
    {
        if (BeginDrag!=null)
        {
            BeginDrag(this.gameObject,eventData);
        }
    }
    public void OnDrag(PointerEventData eventData)
    {
        if (Drag != null)
        {
            Drag(this.gameObject, eventData);
        }
    }
    public void OnEndDrag(PointerEventData eventData)
    {
        if (EndDrag != null)
        {
            EndDrag(this.gameObject, eventData);
        }

    }

    public void OnPointerClick(PointerEventData eventData)
    {
        if (Click!=null)
        {
            Click(this.gameObject,eventData);
        }
    }
    public void OnPointerEnter(PointerEventData eventData)
    {
        if (PointEnter != null)
        {
            PointEnter(this.gameObject, eventData);
        }
    }
    public void OnPointerExit(PointerEventData eventData)
    {
        if (PointExit != null)
        {
            PointExit(this.gameObject, eventData);
        }
    }
    public void OnPointerDown(PointerEventData eventData)
    {
        if (PointDown != null)
        {
            PointDown(this.gameObject, eventData);
        }
    }
}
